$(document).ready(function () {

})

function getRankData(){
    var id = localStorage.getItem(userInfoId);
    var data2="tId="+id;
    $.ajax({
        "url": url + scoreRankByTId,
        "type": 'get',
        "data": data2,
        "dataType": "json",
        "success": function (data) {
            var res = eval('(' + JSON.stringify(data) + ')');
            if (res.resultCode != 200) {
                error(data);
                return;
            }
            htmlFillRank(res.obj);
        },
        "error": error()
    })
}

function getMySc(){
    var id = localStorage.getItem(userInfoId);
    var cId = localStorage.getItem(schoolLoginUserInfo);
    var res = eval('(' + cId + ')');
    show(res.role)
    var data2="tId="+id+"&cId="+res.id;
    $.ajax({
        "url": url + scoreMyToTeacher,
        "type": 'get',
        "data": data2,
        "dataType": "json",
        "success": function (data) {
            var res = eval('(' + JSON.stringify(data) + ')');
            if (res.resultCode != 200) {
                error(data);
                return;
            }
            htmlFillmy(res.obj);
        },
        "error": error()
    })
}


function show(role){
    if(role==1){
        $("#student").show()
    }
    if(role==2){
        $("#teacher").show()
    }
    if(role==3){
        $("#expert").show()
    }
}


function htmlFillUser(info) {
    var infoRes = eval('(' + JSON.stringify(info) + ')');
    $("#name").append(infoRes.name);
    $("#department").append(infoRes.departmentName);
    $("#role").append(roleName(infoRes.role));
    $("#sex").append(sexName(infoRes.sex));
    $("#year").append(workYear(infoRes.startWorkTime));
    $("#direction").append(infoRes.direction);
    $("#title").append(infoRes.title);
    $("#inSchoolTime").append(timestampToTime(infoRes.inSchoolTime));
}

function htmlFillmy(obj){
    if(obj==null || obj == "null"){
        $("#mScore").append(sorecText(obj));
        return
    }
    var res = eval('(' + JSON.stringify(obj) + ')');
    $("#mScore").append(sorecText(res.score));
}

function htmlFillRank(rank){
    var rankRes = eval('(' + JSON.stringify(rank) + ')');
    $("#allSumRank").append(sorecText(rankRes.allSumRank));
    $("#allSumRankScore").append(sorecText(rankRes.allSumRankScore));
    $("#allCountRank").append(sorecText(rankRes.allCountRank));
    $("#allCountRankScore").append(sorecText(rankRes.allCountRankScore));
    $("#allAvgRank").append(sorecText(rankRes.allAvgRank));
    $("#allAvgRankScore").append(sorecText(rankRes.allAvgRankScore));


    $("#depSumRank").append(sorecText(rankRes.depSumRank));
    $("#depSumRankScore").append(sorecText(rankRes.depSumRankScore));
    $("#depCountRank").append(sorecText(rankRes.depCountRank));
    $("#depCountRankScore").append(sorecText(rankRes.depCountRankScore));
    $("#depAvgRank").append(sorecText(rankRes.depAvgRank));
    $("#depAvgRankScore").append(sorecText(rankRes.depAvgRankScore));



}

function stuS(rankRes){
    $("#stuAllSumRank").append(sorecText(rankRes.stuAllSumRank));
    $("#stuAllSumRankScore").append(sorecText(rankRes.stuAllSumRankScore));
    $("#stuAllCountRank").append(sorecText(rankRes.stuAllCountRank));
    $("#stuAllCountRankScore").append(sorecText(rankRes.stuAllCountRankScore));
    $("#stuAllAvgRank").append(sorecText(rankRes.stuAllAvgRank));
    $("#stuAllAvgRankScore").append(sorecText(rankRes.stuAllAvgRankScore));


}

function teaS(rankRes){

    $("#teaAllSumRank").append(sorecText(rankRes.teaAllSumRank));
    $("#teaAllSumRankScore").append(sorecText(rankRes.teaAllSumRankScore));
    $("#teaAllCountRank").append(sorecText(rankRes.teaAllCountRank));
    $("#teaAllCountRankScore").append(sorecText(rankRes.teaAllCountRankScore));
    $("#teaAllAvgRank").append(sorecText(rankRes.teaAllAvgRank));
    $("#teaAllAvgRankScore").append(sorecText(rankRes.teaAllAvgRankScore));


}

function expS(rankRes){
    $("#expAllSumRank").append(sorecText(rankRes.expAllSumRank));
    $("#expAllSumRankScore").append(sorecText(rankRes.expAllSumRankScore));
    $("#expAllCountRank").append(sorecText(rankRes.expAllCountRank));
    $("#expAllCountRankScore").append(sorecText(rankRes.expAllCountRankScore));
    $("#expAllAvgRank").append(sorecText(rankRes.expAllAvgRank));
    $("#expAllAvgRankScore").append(sorecText(rankRes.expAllAvgRankScore));



}


function between(rankRes){
    $("#depBetweenSumRank").append(sorecText(rankRes.depBetweenSumRank));
    $("#depBetweenSumRankScore").append(sorecText(rankRes.depBetweenSumRankScore));
    $("#depBetweenCountRank").append(sorecText(rankRes.depBetweenCountRank));
    $("#depBetweenCountRankScore").append(sorecText(rank.depBetweenCountRankScore));
    $("#depBetweenAvgRank").append(sorecText(rankRes.depBetweenAvgRank));
    $("#depBetweenAvgRankScore").append(sorecText(rankRes.depBetweenAvgRankScore));

    $("#expDepBetweenSumRank").append(sorecText(rankRes.expDepBetweenSumRank));
    $("#expDepBetweenSumRankScore").append(sorecText(rankRes.expDepBetweenSumRankScore));
    $("#expDepBetweenCountRank").append(sorecText(rankRes.expDepBetweenCountRank));
    $("#expDepBetweenCountRankScore").append(sorecText(rankRes.expDepBetweenCountRankScore));
    $("#expDepBetweenAvgRank").append(sorecText(rankRes.expDepBetweenAvgRank));
    $("#expDepBetweenAvgRankScore").append(sorecText(rankRes.expDepBetweenAvgRankScore));

    $("#teaDepBetweenSumRank").append(sorecText(rankRes.teaDepBetweenSumRank));
    $("#teaDepBetweenSumRankScore").append(sorecText(rankRes.teaDepBetweenSumRankScore));
    $("#teaDepBetweenCountRank").append(sorecText(rankRes.teaDepBetweenCountRank));
    $("#teaDepBetweenCountRankScore").append(sorecText(rankRes.teaDepBetweenCountRankScore));
    $("#teaDepBetweenAvgRank").append(sorecText(rankRes.teaDepBetweenAvgRank));
    $("#teaDepBetweenAvgRankScore").append(sorecText(rankRes.teaDepBetweenAvgRankScore));

    $("#stuDepBetweenSumRank").append(sorecText(rankRes.stuDepBetweenSumRank));
    $("#stuDepBetweenSumRankScore").append(sorecText(rankRes.stuDepBetweenSumRankScore));
    $("#stuDepBetweenCountRank").append(sorecText(rankRes.stuDepBetweenCountRank));
    $("#stuDepBetweenCountRankScore").append(sorecText(rankRes.stuDepBetweenCountRankScore));
    $("#stuDepBetweenAvgRank").append(sorecText(rankRes.stuDepBetweenAvgRank));
    $("#stuDepBetweenAvgRankScore").append(sorecText(rankRes.stuDepBetweenAvgRankScore));
}

function dep(rankRes){
    $("#expDepSumRank").append(sorecText(rankRes.expDepSumRank));
    $("#expDepSumRankScore").append(sorecText(rankRes.expDepSumRankScore));
    $("#expDepCountRank").append(sorecText(rankRes.expDepCountRank));
    $("#expDepCountRankScore").append(sorecText(rankRes.expDepCountRankScore));
    $("#expDepAvgRank").append(sorecText(rankRes.expDepAvgRank));
    $("#expDepAvgRankScore").append(sorecText(rankRes.expDepAvgRankScore));


    $("#stuDepSumRank").append(sorecText(rankRes.stuDepSumRank));
    $("#stuDepSumRankScore").append(sorecText(rankRes.stuDepSumRankScore));
    $("#stuDepCountRank").append(sorecText(rankRes.stuDepCountRank));
    $("#stuDepCountRankScore").append(sorecText(rankRes.stuDepCountRankScore));
    $("#stuDepAvgRank").append(sorecText(rankRes.stuDepAvgRank));
    $("#stuDepAvgRankScore").append(sorecText(rankRes.stuDepAvgRankScore));

    $("#teaDepSumRank").append(sorecText(rankRes.teaDepSumRank));
    $("#teaDepSumRankScore").append(sorecText(rankRes.teaDepSumRankScore));
    $("#teaDepCountRank").append(sorecText(rankRes.teaDepCountRank));
    $("#teaDepCountRankScore").append(sorecText(rankRes.teaDepCountRankScore));
    $("#teaDepAvgRank").append(sorecText(rankRes.teaDepAvgRank));
    $("#teaDepAvgRankScore").append(sorecText(rankRes.teaDepAvgRankScore));
}